<template>
    <view class="">
        <view class="p_20"  style="padding-bottom:140rpx">
            <view class="">
                <view class="dis_f_sb_c">
                    <view>
                        <view class="f_s_24">{{infoData.lxrXm}}</view>
                        <view class="dis_f_l_c m_t_10 m_b_10">
                            {{infoData.age}}岁 · {{infoData.education}} · {{infoData.jobBenefits}} · {{infoData.districts}}
                        </view>
                    </view>
                    <view style="position: relative">
                        <u-avatar :src="userData.wxAvatar" size="60"></u-avatar>
                        <view class="p_5 sex_box" :style="{backgroundColor:infoData.sex === '女'?'#FF5182':'#0078FF'}">
                            <u-icon name="woman" v-if="infoData.sex === '女'" size="13" color="#fff"></u-icon>
                            <u-icon name="man" v-else size="13" color="#fff"></u-icon>
                        </view>
                    </view>
                </view>
                <view class="dis_f_sb_c m_t_10">
                    <view class="c_o f_s_12 m_t_10">更新时间：{{infoData.createTime}}</view>
                    <view>
                        <u-button type="primary" @click="handleToTel" size="small">立即联系</u-button>
                    </view>
                </view>
            </view>
            <u-divider></u-divider>
            <view>
                <view class="f_s_18">求职意向</view>
                <view class="f_s_14 m_t_10">{{infoData.bt}}</view>
            </view>
            <u-divider></u-divider>
            <view>
                <view class="f_s_18">查看简历</view>
                <view class="dis_f_l_c m_t_10">
                    <view>
                        <u-button type="primary" @click="handleToPdf" size="small">查看</u-button>
                    </view>
                </view>
            </view>
            <u-divider></u-divider>
            <view v-if="groupData.configName">
            <view  class="jlq_box dis_f_sb_c p_10" @click="handlerToGroup">
                <view class="dis_f_l_c">
                    <image :src="groupData.url" style="width: 100rpx;height: 100rpx;"></image>
                    <view class="m_l_5">
                        <view class="f_s_20 f_w_b">{{groupData.configName}}</view>
                        <view class="f_s_14 m_t_5" style="color:#5FB7EB;">{{groupData.remark}}</view>
                    </view>
                </view>
                <u-icon name="arrow-right"></u-icon>
            </view>
            <u-divider></u-divider>
            </view>
            <view v-if="swiperList.length>0">
                <u-swiper :list="swiperList" indicator hight="200"  imgMode="widthFix" radius="0" indicatorActiveColor="#47C156" indicatorInactiveColor="#dddddd"></u-swiper>
                <u-divider></u-divider>
            </view>
            <view>
                <view>{{infoData.nr}}</view>
            </view>
        </view>
        <!-- 授权弹窗 -->
        <s-auth-modal />
    </view>
</template>

<script>
import {getListInfoApi,addCollectApi,delCollectApi,getByKeyApi,getMyInfoApi} from "@/sheep/api";

export default {
    name: "info",
    data() {
        return {
            getListInfoApi:{},
            src:'',
            swiperList: [],
            safetyReminder: {},
            groupData: {},
            infoData:{},
            userData:{},
            myInfoVo:{},
            queryData:{},
        }
    },
    onLoad(params) {
        this.goodsId = params.goodsId;
        this.queryData.id = params.goodsId
        // this.queryData.lat = uni.getStorageSync('latitude')
        // this.queryData.lot = uni.getStorageSync('longitude')
        this.getInfo()
        this.getMyInfo()
        this.getGroup()
        this.getsafetyReminder()
    },
    onShareAppMessage() {
        return {
            title: '['+this.infoData.typeName+']'+this.infoData.bt,
            imageUrl: this.swiperList[0],
            path: '/pages/index/index'
        }
    },
    methods:{
        handleToPdf(){
            if (!this.userData.pdfUrl){
                uni.showToast({
                    title: '暂无简历',
                    icon: "none",
                    duration: 2000
                });
            }else{
                /*  uni.navigateTo({
                      url: "/pages/index/pdf?url="+this.userData.pdfUrl,
                  });*/
                let that = this
                uni.downloadFile({
                    url: that.userData.pdfUrl,
                    success: function (res) {
                        // 下载成功
                        uni.saveFile({
                            tempFilePath: res.tempFilePath,
                            success: function (res) {
                                /*             uni.showToast({
                                                 title: "下载成功",
                                                 icon: "none",
                                             });*/
                                // 打开文件
                                uni.openDocument({
                                    filePath: res.savedFilePath,
                                    showMenu: true,
                                    success: function () {},
                                });
                            },
                            fail: function (err) {
                                uni.showToast({
                                    title: "下载失败",
                                    icon: "none",
                                });
                            },
                        });
                    },
                });
            }
        },
        handlerToGroup(){
            uni.navigateTo({
                url: "/pages/index/group",
            })
        },
        handleToIssue(){
            uni.navigateTo({
                url: '/pages/mine/addIssue'
            })
        },
        async getGroup() {
            let res = await getByKeyApi("group");
            this.groupData = res.data?.[0];
        },
        async getsafetyReminder() {
            let res = await getByKeyApi("safetyReminder");
            this.safetyReminder = res.data?.[0];
        },
        getMyInfo() {
            getMyInfoApi().then((res) => {
                this.myInfoVo = res.data;
            });
        },
        getInfo(){
            getListInfoApi(this.queryData).then(res=>{
                this.infoData=res.data.vo
                this.userData=res.data.user
                if (res.data.vo.photoUrl){
                    this.swiperList=res.data.vo.photoUrl.split(',')
                }

            })
        },
        handleToTel(){
            uni.makePhoneCall({
                phoneNumber: this.infoData.lxrDh
            })

        },
        handleToIndex(){
            uni.switchTab({
                url: '/pages/index/index'
            });
        },
        handleLike(){
            if (this.infoData.sfxh){
                delCollectApi({inFormationId:this.infoData.id}).then(res=>{
                    uni.showToast({
                        title: res.msg,
                        icon: "none",
                        duration: 2000
                    });
                    if(res.code==200){
                        this.getInfo()
                    }
                })
            }else{
                addCollectApi({userIdPassivity:this.infoData.id}).then(res=>{
                    uni.showToast({
                        title: res.msg,
                        icon: "none",
                        duration: 2000
                    });
                    if(res.code==200){
                        this.getInfo()
                    }
                })
            }
        },
        handleShowNotes(){
            //查看pdf
            uni.navigateTo({
                url: '/pages/index/pdf?url='+this.userData.pdfUrl
            });
        }

    }
}
</script>

<style scoped lang="scss">
.sex_box{
    position: absolute;
    right: 20rpx;
    bottom: 0;
    background-color: #FF5182;
    border-radius: 50%
}
.info_bottom{
    position: fixed;
    bottom: 0;
    padding: 10rpx 50rpx 20rpx;
    width: calc(100% - 100rpx);
    background: #fff;
    border-top:1px solid #cccccc;
}
.jlq_box{
    //背景渐变
    background: linear-gradient(to right, #E7D4FF, #CFEFFE);
    border-radius: 10rpx;
}
</style>
